package com.javaee.web;

import java.util.HashMap;
import java.util.Map;

public class SiteParameters {

	public final static String siteRoot = "/ProjetWebEAR/";
	public final static String jspPath = "/WEB-INF/jsp/";
	public final static String jQuerySrc = "/ProjetWebEAR/js/jquery.js";
	public final static int nbMessageMax = 10;
	// Contient tous les chemins des servlets
	private final static Map<String, String> servletPath;
	// Contient tous les chemins des pages
	private final static Map<String, String> pagePath;
	// Contient tous les chemins des images
	private final static Map<String, String> imagePath;

	static {
		servletPath = new HashMap<String, String>();
		servletPath.put("activity", "activity.jsp");
		servletPath.put("addActivity", "AddActivityServlet");
		servletPath.put("invalidActivity", "InvalidActivityServlet");
		servletPath.put("addConversation", "AddConversationServlet");
		servletPath.put("acceptConversation", "AcceptConversationServlet");
		servletPath.put("interruptConversation", "InterruptConversationServlet");
		servletPath.put("stopConversation", "StopConversationServlet");
		servletPath.put("addEmployee", "AddEmployeeServlet");
		servletPath.put("attachEmployee", "AttachEmployeeServlet");
		servletPath.put("addMessage", "AddMessageServlet");
		servletPath.put("addProject", "AddProjectServlet");
		servletPath.put("administration", "admin.jsp");
		servletPath.put("authentication", "AuthenticationServlet");
		servletPath.put("conversation", "conversation.jsp");
		servletPath.put("cortexTalk", "cortexTalk.jsp");
		servletPath.put("dashboard", "dashboard.jsp");
		servletPath.put("index", "index.jsp");
		servletPath.put("logout", "LogoutServlet");
		servletPath.put("project", "project.jsp");

		pagePath = new HashMap<String, String>();
		pagePath.put("activity", jspPath + "activity.jsp");
		pagePath.put("administration", jspPath + "admin.jsp");
		pagePath.put("conversation", jspPath + "conversation.jsp");
		pagePath.put("cortexTalk", jspPath + "cortexTalk.jsp");
		pagePath.put("dashboard", jspPath + "dashboard.jsp");
		pagePath.put("error", "error.jsp");
		pagePath.put("footer", jspPath + "footer.jsp");
		pagePath.put("header", jspPath + "header.jsp");
		pagePath.put("index", jspPath + "index.jsp");
		pagePath.put("menu", jspPath + "menu.jsp");
		pagePath.put("project", jspPath + "project.jsp");

		imagePath = new HashMap<String, String>();
		imagePath.put("detail", siteRoot + "images/icon_detail.png");
		imagePath.put("edit", siteRoot + "images/icon_edit.png");
		imagePath.put("invalid", siteRoot + "images/icon_invalid.png");
		imagePath.put("reply", siteRoot + "images/icon_reply.png");
		imagePath.put("trash", siteRoot + "images/icon_trash.png");
		imagePath.put("valid", siteRoot + "images/icon_valid.png");
		imagePath.put("exit", siteRoot + "images/icon_exit.png");
		imagePath.put("logout", siteRoot + "images/icon_logout.png");
		imagePath.put("separator", siteRoot + "images/separator.png");
		imagePath.put("write", siteRoot + "images/icon_write.png");
	}

	public static String getFullPagePath(String page) {
		if (pagePath.containsKey(page)) {
			return (siteRoot + pagePath.get(page)).replaceAll("//", "/");
		} else {
			return siteRoot + pagePath.get("error");
		}
	}

	public static String getPagePath(String page) {
		if (pagePath.containsKey(page)) {
			return pagePath.get(page);
		} else {
			return pagePath.get("error");
		}
	}

	public static String getFullServletPath(String servlet) {
		if (servletPath.containsKey(servlet)) {
			return siteRoot + servletPath.get(servlet);
		} else {
			return siteRoot + pagePath.get("error");
		}
	}

	public static String getServletPath(String servlet) {
		if (servletPath.containsKey(servlet)) {
			return servletPath.get(servlet);
		} else {
			return pagePath.get("error");
		}
	}

	public static String getImagePath(String image) {
		if (imagePath.containsKey(image)) {
			return imagePath.get(image);
		} else {
			return "";
		}
	}
}
